package cn.wolfcode.wolf2w.service.imp;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.repository.SpotRepository;
import cn.wolfcode.wolf2w.service.ISpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class SpotServiceImpl implements ISpotService {
    @Autowired
    private SpotRepository spotRepository;

    @Override
    public Spot get(String id) {
        Optional<Spot> optional = spotRepository.findById(id);
        if (optional.isPresent()) {
            return optional.get();
        }
        return null;
    }

    @Override
    public List<Spot> list() {
        return spotRepository.findAll();
    }


    public Spot findById(String id) {
        return spotRepository.findById(id).get();
    }


    @Override
    public void saveOrUpdate(Spot spot) {

    }

    @Override
    public void save(Spot spot) {

    }

    @Override
    public void update(Spot spot) {

    }
}
